package com.ruoyi.bizsys.mapper;

import java.util.List;

import com.ruoyi.bizsys.domain.LoanIou;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.bizsys.vo.LoanIouExtVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.ruoyi.bizsys.vo.LoanIouVo;

/**
 * 贷款借据Mapper接口
 *
 * @author african-loan
 * @date 2021-12-30
 */
public interface LoanIouMapper extends BaseMapper<LoanIou>{

    List<LoanIou> selRepaymentNoApplyAgain();

    int overdueIouCount(@Param("custNo") String custNo, @Param("lastSql") String lastSql);

    List<LoanIou> selRepaymentNoApplyAgainMoreThan10();

    LoanIouExtVo findOneByLoanSerialNo(String loanSerialNo);
    LoanIouExtVo findOneByLoanSerialNoForOne(String loanSerialNo);



    LoanIou getLoanIouDetail(LoanIou loanIouQuery);

    LoanIou getLoanIouByLoanSerialNo(String loanSerialNo);

    void updateReduceAmt(LoanIou loanIou);

    List<LoanIou> getActiveLoanIouByCustNo(String custNo);

    List<LoanIouVo> selectIouTask(String intervalHours);


    /**
     * 通过用户id查询有效拮据表
     * @param custNo 用户id
     * @return
     */
    @Select("select id from loan_iou where cust_no= #{custNo} and (iou_status!=1) LIMIT 1")
    LoanIou selectIou(String custNo);

    void updateLateFee(LoanIou loanIou);

    @Select("select show_interest_rate,show_service_rate,loan_amt from loan_iou where cust_no=#{custNo} ")
    LoanIou getRate(String custNo);

    String selectMinDueData(String custNo);

    String selectzdzhangdanricha(String custNo);

    String getwhdwsjcha2(String custNo);

    /**
     * 入催任务，查询正常的借据列表
     * @param custNo
     * @param repayDate
     * @return
     */
    List<LoanIou> findNormalLoanIous(@Param("custNo")String custNo, @Param("repayDate")String repayDate);

    Integer getHaveDeIou(@Param("custNo")String custNo);

    LoanIou getLoanIouNotSettled(@Param("custNo")String custNo);
    /**
     * 查找到期未结清的借据（包括当天到期和已逾期的借据，如借据已延期则到期日以延期到期日为准）
     * 注意延期
     * @param custNo
     * @return
     */
    List<LoanIou> getCardWithholdIouByCustNo(String custNo);
}
